<?

if (!defined("SAPID_STARTED")) die("Hacking attempt!");

if($MODREWRITE == "disabled" AND $_GET["vpath"]) $_SERVER["REQUEST_URI"] = $_GET["vpath"];
if(!ereg("/$",$_SERVER["REQUEST_URI"])) $_SERVER["REQUEST_URI"].="/";
$http_prefix = preg_replace("/^.*?".preg_replace("/http:\/\//is", "", $_SERVER["HTTP_HOST"])."/is", "", $http_path);
$http_prefix = preg_replace("/\/$/", "", $http_prefix);

$script_uri = $_SERVER["REQUEST_URI"];
if($http_prefix) $script_uri = eregi_replace("^".$http_prefix, "", $script_uri);
$env["argv_string"]=$script_uri=preg_replace("/\?(.*?)$/","",$script_uri);
$noslash_script_uri=preg_replace("/^\//", "", $script_uri);
$env["noslash_argv_string"]=preg_replace("/\/$/", "", $noslash_script_uri);
$uri_array=split("\/", $script_uri);
if(count($uri_array)) {
	foreach($uri_array as $val)	{
		if($val=="data") $sep_flag = true;
		if(!$sep_flag AND !ereg("^\?",$val) AND $val AND $val!="index.php" and $val!="virtual") $env["argv"][]=$val;
		if($sep_flag AND !ereg("^\?",$val) AND $val AND $val!="index.php" and $val!="virtual" and $val!="data") $env["argv_nav"][]=$val;
	}
}
unset($uri_array);
$env["len_argv_nav"] = count($env["argv_nav"]);

// Content of the address string (URL), excluding the navigation part
$env["argv_string"] = join("/",$env["argv"])."/";
if(DEBUG and count($env["argv"])>0 and $env["argv"][ count($env["argv"])-1 ]=="trace"){
	define("TRACE", DEBUG);
	unset($env["argv"][ count($env["argv"])-1 ]);
	$env["argv_string"]=preg_replace("/trace\/$/i", "", $env["argv_string"]);
	$env["noslash_argv_string"]=preg_replace("/trace$/i", "", $env["noslash_argv_string"]);
}else{
	define("TRACE", false);
}


// URL of the document
$env["document.url"] = preg_replace("/\/+$/", "/", $http_path.$env["argv_string"]."/");

?>